package com.ushine.web.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: yls
 * @Date: 2021/08/15 21:51
 * @Description: 添加静态资源访问规则
 * @Version 1.0
 */
@Configuration
@Slf4j
public class BaseWebMvcConfig implements WebMvcConfigurer {

    /**
     * 功能描述:
     * 〈 1、注册本地资源访问规则 〉
     *
     * @param registry 资源注册
     * @return : void
     * @author : yls
     * @date : 2021/08/15 22:01
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        log.info("注册本地资源访问规则：");
        //将所有/static/**访问都映射到classpath:/static/目录下
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }
}
